package com.highspeed.bdk.service.physical;

import com.highspeed.bdk.bean.entity.physical.LinkFoldPoint;
import com.highspeed.bdk.bean.entity.physical.PhysicalLink;
import com.highspeed.bdk.repository.physical.LinkFoldPointRepository;
import com.highspeed.bdk.repository.physical.PhysicalLinkRepository;
import com.highspeed.bdk.service.base.BdkBaseService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by chenjiabin on 2018/3/23.
 *
 * @see IPhysicalLinkService
 */
@Service
@Transactional
public class LinkFoldPointService extends BdkBaseService<LinkFoldPoint, Integer> implements ILinkFoldPointService {
    private static final Log LOG = LogFactory.getLog(LinkFoldPointService.class);
    @Autowired
    private LinkFoldPointRepository repository;

    /**
     * @see IPhysicalLinkService
     */
    @Override
    public LinkFoldPointRepository getRepository() {
        return repository;
    }

    @Override
    public void deleteByLinkId(Integer id) {
        LinkedHashMap params = new LinkedHashMap();
        params.put("physicalLink.id_eq", id);
        List<LinkFoldPoint> foldPoints = queryToList(params, null);
        if (!foldPoints.isEmpty()) {
            repository.deleteInBatch(foldPoints);
        }
    }
}
